<template>
  <div>
    <el-calendar v-model="value">
      <template slot="dateCell" slot-scope="{ data }">
        <a href="http://localhost:8080/#/sys/attendance_apply">
          <!--这里原本有动态绑定的class，去掉-->
          {{ data.day.split("-").slice(2).join("-") }}
        </a><span style="color:red"   v-show="sevendealMyDate(data.day)!=null" @click="SevenEdit(sevendealMyDateid(data.day))">{{ sevendealMyDate(data.day) }}(审批中)</span>        <br />      
        <span style="color:red"   v-show="onedealMyDate(data.day)!=null" @click="Edit(onedealMyDateid(data.day))">{{ onedealMyDate(data.day) }}(审批中)</span> <span  v-show="twodealMyDate(data.day)!=null"  @click="TwoEdit(twodealMyDateid(data.day))" style="color:red">{{twodealMyDate(data.day) }}(审批中)</span><br> 
        <span style="color:red"   v-show="threedealMyDate(data.day)!=null" @click="ThreeEdit(threedealMyDateid(data.day))">{{ threedealMyDate(data.day) }}(审批中)</span> <span  v-show="fourdealMyDate(data.day)!=null"  @click="FourEdit(fourdealMyDateid(data.day))" style="color:red">{{fourdealMyDate(data.day) }}(审批中)</span><br>  
        <span style="color:red"   v-show="fivedealMyDate(data.day)!=null" @click="FiveEdit(fivedealMyDateid(data.day))">{{ fivedealMyDate(data.day) }}(审批中)</span> <span  v-show="sixdealMyDate(data.day)!=null"  @click="SixEdit(sixdealMyDateid(data.day))" style="color:red">{{sixdealMyDate(data.day) }}(审批中)</span><br>  
        
      </template>
    </el-calendar>
    <el-dialog
  title="申请记录"
  :visible.sync="centerDialogVisible"
  width="30%"
  center>
  <el-form ref="form" :model="showform" label-width="80px">
  <el-form-item label="申请状态:">
     {{showform.whether_through==0?'审核中':''}}
  </el-form-item>
  <el-form-item label="申请类型:">
      {{showform.application_type}}
  </el-form-item>
  <el-form-item label="申请原因:">
      {{showform.apply_reason}}
  </el-form-item>
  <el-form-item label="时间:">
    {{dateto(showform.create_time)}}-----{{dateto(showform.end_time)}}
  </el-form-item>
  <el-form-item label="考勤统计:">
      {{showform.attendance_statistics}}
  </el-form-item>
  <el-form-item label="申请人:">
      {{showform.creator_name}}
  </el-form-item>
  <el-form-item label="备注:">
      {{showform.note_information}}
  </el-form-item>
  </el-form>
</el-dialog>

  </div> 
</template>
<script>
import { GetAllApplicationType,Edit,TwoEdit,ThreeEdit,FourEdit,FiveEdit,SixEdit,SevenEdit } from "./AttendanceManagementApi";
import moment from 'moment';
export default {
  data() {
    return {
      value: new Date(),
      resDate: [],
      showform:{},
      centerDialogVisible:false,
    };
  },
  created() {
    this.GetAllApplicationType();
  },
  methods: {
    //时间方法
    dateto(a){
     var  value=moment(a).format('MM月DD日 HH时mm分')
return value
    },
    //获取所有数据
    GetAllApplicationType() {
      GetAllApplicationType().then((res) => {
        this.resDate = res.data;
      });
    },
    //返回对应的申请
    onedealMyDate(v) {
      var one = this.resDate.one;
      for (let i = 0; i < one.length; i++) {
        if (one[i].create_time.substr(0, 10) == v) {
          var res = one[i].application_type;
          break;
        }
      }
      return res;
    },
     twodealMyDate(v) {
      var one = this.resDate.two;
      for (let i = 0; i < one.length; i++) {
        if (one[i].create_time.substr(0, 10) == v) {
          var res = one[i].application_type;
          break;
        }
      }
      return res;
    },
      threedealMyDate(v) {
      var one = this.resDate.three;
      for (let i = 0; i < one.length; i++) {
        if (one[i].create_time.substr(0, 10) == v) {
          var res = one[i].application_type;
          break;
        }
      }
      return res;
    },
     fourdealMyDate(v) {
      var one = this.resDate.four;
      for (let i = 0; i < one.length; i++) {
        if (one[i].create_time.substr(0, 10) == v) {
          var res = one[i].application_type;
          break;
        }
      }
      return res;
    },
      fivedealMyDate(v) {
      var one = this.resDate.five;
      for (let i = 0; i < one.length; i++) {
        if (one[i].create_time.substr(0, 10) == v) {
          var res = one[i].application_type;
          break;
        }
      }
      return res;
    },
      sixdealMyDate(v) {
      var one = this.resDate.six;
      for (let i = 0; i < one.length; i++) {
        if (one[i].create_time.substr(0, 10) == v) {
          var res = one[i].application_type;
          break;
        }
      }
      return res;
    },
      sevendealMyDate(v) {
      var one = this.resDate.seven;
      for (let i = 0; i < one.length; i++) {
        if (one[i].create_time.substr(0, 10) == v) {
          var res = one[i].application_type;
          break;
        }
      }
      return res;
    },
    //获取每个类型的反填id
     onedealMyDateid(v) {
      var one = this.resDate.one;
      for (let i = 0; i < one.length; i++) {
        if (one[i].create_time.substr(0, 10) == v) {
          var res = one[i].leave_id;
          break;
        }
      }
      return res;
    },
     twodealMyDateid(v) {
      var one = this.resDate.two;
      for (let i = 0; i < one.length; i++) {
        if (one[i].create_time.substr(0, 10) == v) {
          var res = one[i].business_travel_request_id;
          break;
        }
      }
      return res;
    },
     threedealMyDateid(v) {
      var one = this.resDate.three;
      for (let i = 0; i < one.length; i++) {
        if (one[i].create_time.substr(0, 10) == v) {
          var res = one[i].field_application_id;
          break;
        }
      }
      return res;
    },
    fourdealMyDateid(v) {
      var one = this.resDate.four;
      for (let i = 0; i < one.length; i++) {
        if (one[i].create_time.substr(0, 10) == v) {
          var res = one[i].not_clock_id;
          break;
        }
      }
      return res;
    },
     fivedealMyDateid(v) {
      var one = this.resDate.five;
      for (let i = 0; i < one.length; i++) {
        if (one[i].create_time.substr(0, 10) == v) {
          var res = one[i].company_activities_id;
          break;
        }
      }
      return res;
    },
     sixdealMyDateid(v) {
      var one = this.resDate.six;
      for (let i = 0; i < one.length; i++) {
        if (one[i].create_time.substr(0, 10) == v) {
          var res = one[i].department_activity_id;
          break;
        }
      }
      return res;
    },
     sevendealMyDateid(v) {
      var one = this.resDate.seven;
      for (let i = 0; i < one.length; i++) {
        if (one[i].create_time.substr(0, 10) == v) {
          var res = one[i].work_overtime_leave_id;
          break;
        }
      }
      return res;
    },

//向api发送反填请求
    Edit(id){
     this.centerDialogVisible=true;
      Edit(id).then((res)=>{
      this.showform=res.data;       
      })
    },
     TwoEdit(id){
     this.centerDialogVisible=true;
      TwoEdit(id).then((res)=>{
      this.showform=res.data;       
      })
    },
     ThreeEdit(id){
     this.centerDialogVisible=true;
      ThreeEdit(id).then((res)=>{
      this.showform=res.data;       
      })
    },
     FourEdit(id){
     this.centerDialogVisible=true;
      FourEdit(id).then((res)=>{
      this.showform=res.data;       
      })
    },
     FiveEdit(id){
     this.centerDialogVisible=true;
      FiveEdit(id).then((res)=>{
      this.showform=res.data;       
      })
    },
     SixEdit(id){
     this.centerDialogVisible=true;
      SixEdit(id).then((res)=>{
      this.showform=res.data;       
      })
    },
     SevenEdit(id){
     this.centerDialogVisible=true;
      SevenEdit(id).then((res)=>{
      this.showform=res.data;       
      })
    }
    
  },
};
</script>